<?php
/*####################
# Potrebni funkcii
# 
#
####################*/

require_once('includes/db.php');

/*
# Funkcija za zemeanje na atribut - vraka vrednost na atributot
*/
function getAttrib($tag,$attrib,$src)
{
	$value=explode($tag,$src);
	$attrib.="=\"";
	$value=explode($attrib,$value[1]);
	$value=explode("\"",$value[1]);
	return $value[0];
}

/*
# Funkcija za proverka dali odreden string sodrzi drug string
*/
function contains($str, $content){
$ignorecase = 1;
    if ($ignorecase){
        $str = strtolower($str);
        $content = strtolower($content);
    }  
    return strpos($content,$str) ? true : false;
}

/*
# Funckija sto ja vraka momentalnata vremenska sostojba spored soodveten kod
*/
function getCond($code,$lang){
	$connector=new DbConnector();
	$qu="SELECT $lang FROM sostojba WHERE condid=$code";
	$result = $connector->query($qu);
	$row = $connector->fetchArray($result);
	return $row[$lang];
}

/*
# Funckija sto ja dava priblizno lokacijata na posetitelot spored IP adresata
*/
function getLoc($ip){
	$url="http://www.melissadata.com/Lookups/iplocation.asp?ipaddress=".$ip;
	$src=file_get_contents($url);
	$city=explode("City</td><td><b>",$src);
	$city=explode("</b></td>",$city[1]);
	return $city[0];
}


function getAKey()
	{
		$conf = ConfClass::getSettings();
		$apikey=$conf['apikey'];
		return $apikey;
	}


?>